//
//  MainTabBarController.swift
//  声网demo
//
//  Created by 秦江涛 on 2022/9/8.
//

import UIKit

class MainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.tabBar.backgroundColor = .white
        
        setTableBar()
//        setupChildController()
    }
    

    func setTableBar() {
        UITabBar.appearance().backgroundColor = .white
        
        addChildViewController(viewCtl: HomeViewController(), title: "分析概览", imageName: "分析概览")
        addChildViewController(viewCtl: AIHealthScanViewController(), title: "AI健康扫描", imageName: "AI健康扫描")
        addChildViewController(viewCtl: CalendarViewController(), title: "健康日历", imageName: "健康日历")
        addChildViewController(viewCtl: MyViewController(), title: "我的资料", imageName: "我的资料")
        
        // 选中字体颜色
        self.tabBar.tintColor = MainColor
    }
    
    func addChildViewController(viewCtl: UIViewController, title: String, imageName: String) {
        viewCtl.tabBarItem.image = UIImage(named: imageName)?.withRenderingMode(.alwaysOriginal)
        viewCtl.tabBarItem.selectedImage = UIImage(named: "\(imageName)_select")?.withRenderingMode(.alwaysOriginal)
        viewCtl.title = title
        let nav = MainNavigationController(rootViewController: viewCtl)
        self.addChild(nav)
    }
    
}



extension Bundle {

    // 计算型属性类似于函数，没有参数，有返回值
    var namespace: String {
        return infoDictionary?["CFBundleName"] as? String ?? ""
    }
}

